<?php
/**
 * @var user Customer at tbl_customer 
 */
/**
 * @var CActiveRecord  Customer at tbl_user  
 */
//$u=$user->user;
?>
<div class="user-quick-detail">
    <div class="uqd-avatar">

        <img width="70px"
             src="<?php echo $u->getAvartBySize(70, 70); ?>" alt="<?php echo htmlentities($u->name, ENT_QUOTES) ?>"/>
    </div>
    <div class="uqd-info">
        <strong><?php echo htmlentities($u->name, ENT_QUOTES) ?></strong>

        <?php if (isset($u->birthday) && !empty($u->birthday)): ?>
            <br/>
            <span class="text-small">
                <?php echo date('d/M/Y', $u->birthday) ?>
            </span>
        <?php endif; ?>

        <?php if (isset($u->phone)): ?>
            <br/>
            <span class="text-small"><?php echo $u->phone ?></span>
        <?php endif; ?>

        <?php if (isset($u->address)): ?>
            <br/>
            <span class="text-small"><?php echo $u->fullAddress ?></span>
        <?php endif; ?>
        <div class="clearfix"></div>
        <span class="text-small"><a target="_blank" href="<?php echo $user->editUrl ?>"><u>More details</u></a></span>
    </div>

    <div class="clearfix"></div>

    <div class="row-fluid text-small">
        <div class="span6">
            <i class="icon-arrow-left"></i> <b>Prev Appointment</b>
            <?php
            $max_appt = AptCustomer::getPrevAppt($user->ckey);
            ?>
            <?php if ($max_appt != FALSE AND ! empty($max_appt)): ?>
                <?php
                $appt_prev = Appoint::model()->findByPk($max_appt['id']);
                ?>
                <?php if ($appt_prev): ?>
                    <table class="table table-bordered table-striped">
                        <tbody>
                            <tr>
                                <td>
                                    <b>Service/Room:</b> <?php echo htmlentities($appt_prev->service->s_name, ENT_QUOTES); ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>From:</b> <?php echo $appt_prev->start_time; ?> to <?php echo $appt_prev->end_time; ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>At:</b> <?php echo date('d/M/Y', $appt_prev->date); ?>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                <?php endif; ?>
            <?php else: ?>
                <div class="alert alert-error">
                    No Appointment found.
                </div>
            <?php endif; ?>
        </div>

        <div class="span6">
            <b>Next Appointment</b> <i class="icon-arrow-right"></i>
            <?php $min_appt = AptCustomer::getNextAppt($user->ckey); ?>
            <?php if ($min_appt != FALSE): ?>
                <?php
                $appt_next = Appoint::model()->findByPk($min_appt['id']);
                ?>
                <?php if ($appt_next): ?>
                    <table class="table table-bordered table-striped">
                        <tbody>
                            <tr>
                                <td>
                                    <b>Service/Room:</b>  <?php echo htmlentities($appt_next->service->s_name, ENT_QUOTES); ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>From:</b> <?php echo $appt_next->start_time; ?> to <?php echo $appt_next->end_time; ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>At:</b> <?php echo date('d/M/Y', $appt_next->date); ?>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                <?php endif; ?>

            <?php else: ?>
                <div class="alert alert-error">
                    No Appointment found.
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>
